stage.set_axis(8)
stage.create_grid_overlay(1, "black")
x_label = codesters.Text("x", 7.5, -.5)
x_label.set_size(.8)
y_label = codesters.Text("y", .3, 7.5)
y_label.set_size(.8)
def arrow(axis, scale, color):
if axis == "x":
top1 = codesters.Line(scale, 0, scale - .3, .5, color)
bottom1 = codesters.Line(scale, 0, scale - .3, -.5, color)
top2 = codesters.Line(-scale, 0, -scale + .3, .5, color)
bottom2 = codesters.Line(-scale, 0, -scale + .3, -.5, color)
if axis == "y":
top1 = codesters.Line(0, scale, .5, scale -.3, color)
bottom1 = codesters.Line(0, scale, -.5, scale-.3, color)
top2 = codesters.Line(0, -scale, .5, -scale +.3, color)
bottom2 = codesters.Line(0, -scale, -.5 , -scale + .3, color)
arrow("x", 8, "black")
arrow("y", 8, "black")
x_highlight = codesters.Rectangle(0, 0, 16, .2, "yellow")
y_highlight = codesters.Rectangle(0, 0, .2, 16, "yellow")
x_highlight.hide()
y_highlight.hide()
origin_marker = codesters.Circle(0, 0, .5, None, "blue")
origin_label = codesters.Text("origin", 1, .5, "grey")
point_1 = codesters.Point(4, 3, .25)
point_1.set_color(None)
point_1_label = codesters.Text(" ", 4, 4, "blue")
point_2 = codesters.Point(-3, 2)
point_2.set_color("green")
point_2.set_opacity(0)
point_2.set_size(1)
point_2_label = codesters.Text(" ", -3, 3, "green")
point_2x = codesters.Point(-3, 0)
point_2x.set_color(None)
point_3 = codesters.Point(5,0)
point_3.set_color("purple")
point_3.set_opacity(.1)
point_3x_text = codesters.Text(" ", 4, -.8)
point_3y_text = codesters.Text(" ", 4, -1.3)
x_axis = codesters.Text(" ", 6, -1, "green")
y_axis = codesters.Text(" ", 2, 7.5, "green")
nar_rect = codesters.Rectangle(0, 6, 12, 2.5, "lightgreen")
nar= codesters.Text("This is a coordinate plane.", 0, 6)
click_rect = codesters.Rectangle(-5.5, -7.5, 5, 1, "lightblue")
rect_text = codesters.Text("Click to continue", -5.5, -7.5, "black")
move_label_x = codesters.Text(" ", 2, -1, "green")
move_label_y = codesters.Text(" ", 6, 1.5, "green")
jump_lines_x = []
jump_lines_y =[]
def jump_x(x_coord):
# sprite = codesters.Curve(x1, y1, cp1x, cp1y, cp2x, cp2y, x2, y2, fill, "color")
if x_coord >=0:
jump = 1
start_x = 0
for counter in range(x_coord):
jump_line_x = codesters.Curve(start_x, 0, start_x+.5, .5, start_x+.5, .5, jump, 0, "green", "green")
jump += 1
start_x +=1
jump_lines_x.append(jump_line_x)
stage.wait(.2)
if x_coord < 0:
jump = -1
start_x = 0
for counter in range(abs(x_coord)):
jump_line_x = codesters.Curve(start_x, 0, start_x-.5, .5, start_x-.5, .5, jump, 0, "green", "green")
jump -= 1
start_x -=1
jump_lines_x.append(jump_line_x)
stage.wait(.2)
def jump_y(x_coord, y_coord):
jump = 1
start_y = 0
for counter in range(y_coord):
# sprite = codesters.Curve(x1, y1, cp1x, cp1y, cp2x, cp2y, x2, y2, fill, "color")
jump_line_y = codesters.Curve(x_coord, start_y, x_coord + .5, start_y + .5, x_coord + .5, start_y + .5, x_coord, jump, "green", "green")
jump += 1
start_y +=1
jump_lines_y.append(jump_line_y)
stage.wait(.2)
def wrong_click():
rect_text.set_text("Click the x-axis.")
def click_1():
rect_text.set_text(" ")
nar.set_text("The coordinate plane is formed \n by an x-axis and a y-axis.")
nar.set_y(6.5)
x_axis.set_text("X Axis")
y_axis.set_text("Y Axis")
x_highlight.show()
y_highlight.show()
rect_text.set_text("Click to continue.")
click_rect.event_click(click_2)
def click_2():
y_axis.hide()
rect_text.set_text(' ')
y_highlight.hide()
nar.set_text("The x-axis is a horizontal number \nline, running side to side.")
x_highlight.show()
stage.wait(.5)
rect_text.set_text("Click to continue.")
click_rect.event_click(click_3)
def click_3():
rect_text.set_text(' ')
x_axis.hide()
x_highlight.hide()
y_highlight.show()
y_axis.show()
nar.set_text("The y-axis is a vertical number \nline, running up and down.")
stage.wait(.5)
rect_text.set_text("Click to continue.")
click_rect.event_click(click_4)
def click_4():
y_axis.hide()
y_highlight.hide()
rect_text.set_text(' ')
nar.set_text("The x and y axis intersect at \nthe origin, point (0, 0).")
origin_label.set_color("green")
origin_label.set_size(1.1)
origin_label.set_position(2, 1)
origin_marker.set_color("green")
stage.wait(.5)
rect_text.set_text("Click to continue.")
click_rect.event_click(click_5)
def click_5():
rect_text.set_text(' ')
origin_label.hide()
nar.set_text("We name points by their\n horizontal and vertical distance\n from the origin.")
jump_x(4)
move_label_x.set_text('4 units')
jump_y(4,3)
move_label_y.set_text("3 units")
stage.wait(.5)
point_1.set_color("blue")
point_1_label.set_text("Point 1: (4, 3)")
rect_text.set_text("Click to continue.")
click_rect.event_click(click_6)
def click_6():
rect_text.set_text(' ')
click_rect.hide()
for i in jump_lines_x:
i.hide()
for i in jump_lines_y:
i.hide()
move_label_x.set_text(' ')
move_label_y.set_text(' ')
nar_rect.set_position(-3, 7)
nar.set_position(-2.5, 7.5)
nar.set_text("Now you try plotting a point at (-3, 2) \n Click -3 on the x-axis.")
stage.wait(.5)
rect_text.set_x(-4)
point_2x.set_color("black")
point_2x.event_click(click_7)
click_rect.event_click(wrong_click)
def click_7():
rect_text.set_text(" ")
click_rect.hide()
jump_x(-3)
nar.set_text("Great! Now count up to 2 \nand click on the intersection!")
stage.wait(.5)
point_2.set_opacity(.5)
point_2.event_click(click_8)
def click_8():
point_2.set_opacity(1)
jump_y(-3, 2)
nar.set_text("Great job! \n Click submit and next to continue!")
point_2_label.set_text("Point 2: (-3, 2)")
point_2x.hide()
for i in jump_lines_x:
i.hide()
for i in jump_lines_y:
i.hide()
click_rect.event_click(click_1)